import request from '../utils/request';

// 车辆管理相关API
export const vehicleApi = {
  // 获取车辆列表
  getVehicleList: (params) => {
    return request.get('/api/vehicles', { params });
  },

  // 获取车辆详情
  getVehicleDetail: (id) => {
    return request.get(`/api/vehicles/${id}`);
  },

  // 创建车辆
  createVehicle: (data) => {
    return request.post('/api/vehicles', data);
  },

  // 更新车辆
  updateVehicle: (id, data) => {
    return request.put(`/api/vehicles/${id}`, data);
  },

  // 删除车辆
  deleteVehicle: (id) => {
    return request.delete(`/api/vehicles/${id}`);
  },

  // 获取车辆使用记录
  getVehicleUsage: (vehicleId, params) => {
    return request.get(`/api/vehicles/${vehicleId}/usage`, { params });
  },

  // 申请用车
  applyVehicle: (data) => {
    return request.post('/api/vehicles/apply', data);
  },

  // 审批用车申请
  approveVehicleApplication: (id, data) => {
    return request.post(`/api/vehicles/applications/${id}/approve`, data);
  },

  // 拒绝用车申请
  rejectVehicleApplication: (id, data) => {
    return request.post(`/api/vehicles/applications/${id}/reject`, data);
  },

  // 获取用车申请列表
  getVehicleApplications: (params) => {
    return request.get('/api/vehicles/applications', { params });
  },

  // 获取我的用车申请
  getMyVehicleApplications: (params) => {
    return request.get('/api/vehicles/applications/my', { params });
  },

  // 车辆维修记录
  getVehicleMaintenance: (vehicleId, params) => {
    return request.get(`/api/vehicles/${vehicleId}/maintenance`, { params });
  },

  // 添加维修记录
  addMaintenanceRecord: (vehicleId, data) => {
    return request.post(`/api/vehicles/${vehicleId}/maintenance`, data);
  },

  // 更新维修记录
  updateMaintenanceRecord: (vehicleId, recordId, data) => {
    return request.put(`/api/vehicles/${vehicleId}/maintenance/${recordId}`, data);
  },

  // 删除维修记录
  deleteMaintenanceRecord: (vehicleId, recordId) => {
    return request.delete(`/api/vehicles/${vehicleId}/maintenance/${recordId}`);
  },

  // 获取车辆统计
  getVehicleStatistics: (params) => {
    return request.get('/api/vehicles/statistics', { params });
  },

  // 获取车辆状态
  getVehicleStatus: (vehicleId) => {
    return request.get(`/api/vehicles/${vehicleId}/status`);
  },

  // 更新车辆状态
  updateVehicleStatus: (vehicleId, data) => {
    return request.put(`/api/vehicles/${vehicleId}/status`, data);
  }
};
